home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 4116
- ClientLeft = 1644
- ClientTop = 7236
- ClientWidth = 5772
- Height = 4500
- Left = 1596
- LinkTopic = "Form1"
- ScaleHeight = 4116
- ScaleWidth = 5772
- Top = 6900
- Width = 5868
- Begin VB.TextBox txtaddress
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Arial Black"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 456
- Left = 360
- TabIndex = 9
- Top = 3360
- Width = 1572
- End
- Begin VB.TextBox txtbitsize
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Arial Black"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 456
- Left = 360
- TabIndex = 8
- Top = 2640
- Width = 1572
- End
- Begin VB.CommandButton cmdexit
- Caption = "E&xit"
- Height = 372
- Left = 2400
- TabIndex = 7
- Top = 3360
- Width = 732
- End
- Begin VB.CommandButton cmdbitsize
- Caption = "&Toggle Bit size"
- Height = 372
- Left = 2160
- TabIndex = 6
- Top = 2640
- Width = 1332
- End
- Begin VB.CommandButton cmdread
- Caption = "&Read from port"
- Height = 372
- Left = 2160
- TabIndex = 5
- Top = 1920
- Width = 1332
- End
- Begin VB.TextBox txtusread
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Arial Black"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 456
- Left = 3720
- TabIndex = 4
- Top = 1920
- Width = 1692
- End
- Begin VB.TextBox txtvalue
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Arial Black"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 456
- Left = 360
- TabIndex = 3
- Top = 1920
- Width = 1572
- End
- Begin VB.TextBox txtuswrite
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Arial Black"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 456
- Left = 3720
- TabIndex = 2
- Top = 1200
- Width = 1692
- End
- Begin VB.TextBox txtwrite
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Arial Black"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 456
- Left = 360
- TabIndex = 1
- Top = 1200
- Width = 1572
- End
- Begin VB.CommandButton cmdwrite
- Caption = "&Write to port"
- Height = 372
- Left = 2160
- TabIndex = 0
- Top = 1200
- Width = 1332
- End
- Begin VB.Label lblwrite
- Caption = "Value to Write"
- Height = 252
- Left = 360
- TabIndex = 17
- Top = 960
- Width = 1572
- End
- Begin VB.Label lblread
- Caption = "Value Read"
- Height = 252
- Left = 360
- TabIndex = 16
- Top = 1680
- Width = 1572
- End
- Begin VB.Label lblbitsize
- Caption = "Size in Bits"
- Height = 252
- Left = 360
- TabIndex = 15
- Top = 2400
- Width = 972
- End
- Begin VB.Label lbladdress
- Caption = "I/O Port Address"
- Height = 252
- Left = 360
- TabIndex = 14
- Top = 3120
- Width = 1452
- End
- Begin VB.Label lblusread
- Height = 252
- Left = 3720
- TabIndex = 13
- Top = 1680
- Width = 1812
- End
- Begin VB.Label lbluswrite
- Height = 252
- Left = 3720
- TabIndex = 12
- Top = 960
- Width = 1692
- End
- Begin IOPORTLib.Ioport Ioport1
- Left = 4080
- Top = 2880
- _Version = 65536
- _ExtentX = 1503
- _ExtentY = 1503
- _StockProps = 0
- End
- Begin VB.Label Label2
- Caption = "(For Visual Basic 4.0 Using IOPORT OCX)"
- Height = 252
- Left = 1320
- TabIndex = 11
- Top = 600
- Width = 3132
- End
- Begin VB.Label Label1
- BackColor = &H00C0C0C0&
- Caption = "IOPORT Test Program"
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Arial"
- Size = 19.8
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF0000&
- Height = 492
- Left = 840
- TabIndex = 10
- Top = 120
- Width = 4212
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- 'if the "toggle Bit Size" button is clicked
- Private Sub cmdbitsize_Click()
- 'then if the IOPORT.bitsize property is currently the value 8
- 'change it to 16 and change the labels above the "write" and "read"
- 'textboxes to reflect signed and unsigned 16-bit values are being
- 'displayed
- If Val(txtbitsize.Text) = 8 Then
- txtbitsize.Text = 16
- Ioport1.bitsize = 16
- lbluswrite.Caption = "Unsigned value Write"
- lblusread.Caption = "Unsigned value Read"
- lblwrite.Caption = "Signed value Write"
- lblread.Caption = "Signed value Read"
- 'but if the IOPORT.bitsize property is currently the value 16
- 'then change it to 8 and change the labels above the "write" and "read"
- 'textboxes to reflect only 8-bit values are being displayed
- txtbitsize.Text = 8
- Ioport1.bitsize = 8
- lbluswrite.Caption = ""
- lblusread.Caption = ""
- lblwrite.Caption = "Value to Write"
- lblread.Caption = "Value Read"
- End If
- 'now clear all read and write text boxes
- txtwrite.Text = ""
- txtvalue.Text = ""
- txtuswrite.Text = ""
- txtusread.Text = ""
- End Sub
- 'if the "Exit" button is clicked then end the program
- Private Sub cmdexit_Click()
- End Sub
- 'if the "Read from Port" button is clicked
- Private Sub cmdread_Click()
- 'then if the IOPORT.bitsize value is 8
- 'read the value of IOPORT.value to the "Value read" text box and
- 'ensure that the "Unsigned value Read" textbox is blank.
- If Val(Ioport1.bitsize) = 8 Then
- txtvalue.Text = Ioport1.Value
- txtusread.Text = ""
- 'but if the IOPORT.bitsize value is 16
- 'then read the value of IOPORT.value and display it in the "Value read"
- 'textbox and read the value of IOPORT.USValue and display it in the
- '"Unsigned value Read" textbox
- Else
- txtvalue.Text = Ioport1.Value
- txtusread.Text = Ioport1.USValue
- End If
- End Sub
- 'if the "Write to Port" button is clicked
- Private Sub cmdwrite_Click()
- 'then if the IOPORT.bitzise value is 8 then send the value of the
- '"Value to Write" text box to the port and ensure that the "Unsigned
- 'value to Write" text box is blank
- If Val(Ioport1.bitsize) = 8 Then
- Ioport1.Value = Val(txtwrite.Text)
- txtuswrite.Text = ""
- 'but if the IOPORT.bitsize value is 16 then there are two posibilities:
- 'either the user wishes to write a signed 16-bit value, or the user wishes
- 'to write an unsigned 16-bit value, the text boxes must be checked to find
- 'out which 16-bit format to write
- Else
- 'first check to see if there is data in the "Unsigned value to Write"
- 'text box, if so this is the format that will be written to the
- 'IOPORT.USValue and the "Signed value to Write" text box will be blanked
- If (txtuswrite.Text <> "") Then
- Ioport1.USValue = Val(txtuswrite.Text)
- txtwrite.Text = ""
- 'otherwise the data in the "Signed value to Write" will be written to the
- 'IOPORT.USValue and the "Unsigned value to Write" will be blanked
- Else
- Ioport1.USValue = Val(txtwrite.Text)
- txtuswrite.Text = ""
- End If
-
- End If
- End Sub
- 'When the IOTEST application is first loaded...
- Private Sub Form_Load()
- 'then set these variables to these values....
- address = 888
- bitsize = 8
- Value = 0
- 'and display these values in the appropriate text boxes...
- txtaddress = address
- txtbitsize = bitsize
- txtvalue = Value
- End Sub
- 'When a user clicks on the "I/O Port Address" text box...
- Private Sub txtaddress_Click()
- 'clear it out to receive a new address value from the user
- txtaddress.Text = ""
- End Sub
- 'When a user enters a number in the "I/O Port Address" text box
- 'and then hits ENTER, (ENTER causes the variable: "KeyAscii" to be equal to 13)
- Private Sub txtaddress_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- 'as long as the value entered is between 0 and 65535..
- If Val(txtaddress.Text >= 0) And Val(txtaddress.Text <= 65535) Then
-
- 'then set the IOPORT.address to this new value
- Ioport1.address = Val(txtaddress.Text)
-
- 'otherwise the value entered is out of range, send an error message
- 'to the user.
- Else
- MsgBox "I/O Address must be between 0 and 65535!", vbExclamation, "Address Value ERROR"
-
- End If
- End If
- End Sub
- 'When the user clicks on the "Unsigned value to Write" text box...
- Private Sub txtuswrite_Click()
- 'clear it out to receive a new unsigned write value from the user
- txtuswrite.Text = ""
- End Sub
- 'When a user enters a number in the "Unsigned value to Write" text box
- 'and then hits ENTER, (ENTER causes the variable: "KeyAscii" to be equal to 13)
- Private Sub txtuswrite_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- 'as long as the value is between 0 and 65535...
- If (Val(txtuswrite.Text) >= 0) And (Val(txtuswrite.Text) <= 65535) Then
-
- 'set the IOPORT.USValue to this number
- Ioport1.USValue = Val(txtuswrite.Text)
-
- 'otherwise the wrong value was entered, send an error message to the user
- Else
- MsgBox "Unsigned Write value must be between 0 and 65535!", vbExclamation, "Unsigned Write Value ERROR"
-
- 'clear out the "Unsigned value to Write" text box..
- txtuswrite.Text = ""
- End If
- End If
- End Sub
- 'when a user clicks on the "Value to Write" or "Signed value to Write" text box
- '(which is the same box, its title depends on 8-bit or 16-bit mode as shown
- 'in "Size in Bits" text box)
- Private Sub txtwrite_Click()
- 'clear it out to receive a new write value from the user
- txtwrite.Text = ""
- End Sub
- 'When a user enters a number in the "Value to Write" text box
- 'and then hits ENTER, (ENTER causes the variable: "KeyAscii" to be equal to 13)
- Private Sub txtwrite_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- 'check to see if IOPORT1.Bitsize is 16
- If Val(Ioport1.bitsize) = 16 Then
- 'if bitsize is 16 we must only allow values between -32767 and +32768
- If (Val(txtwrite.Text) >= -32767) And (Val(txtwrite.Text) <= 32768) Then
-
- 'set the IOPORT.USValue to this number
- Ioport1.Value = Val(txtwrite.Text)
-
- 'otherwise the wrong value was entered, send an error message to the user
- Else
- MsgBox "Signed Write value must be between -32767 and 32678!", vbExclamation, "Signed Write Value ERROR"
-
- 'clear out the "Signed value to Write" text box...
- txtwrite.Text = ""
- End If
-
- 'if instead, IOPORT1.bitsize is 8..
- Else
- 'as long as the value entered is between 0 and 255...
- If (Val(txtwrite.Text) >= 0) And (Val(txtwrite.Text) <= 255) Then
-
- 'set the IOPORT.value to this number
- Ioport1.Value = Val(txtwrite.Text)
-
- 'otherwise the wrong value was entered, send an error message to the user
- Else
- MsgBox "Write value must be between 0 and 255!", vbExclamation, "Write Value ERROR"
-
- 'clear out the "Value to Write" text box..
- txtwrite.Text = ""
- End If
-
- End If
- End If
- End Sub
-